package com.nbgs.demo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nbgs.demo.common.Result;
import com.nbgs.demo.info.AllInfo;
import com.nbgs.demo.info.ShowUserEnteringInfo;
import com.nbgs.demo.service.ShowUserServiceInterface;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;

@CrossOrigin("*")
@Slf4j
@RestController
@Api(tags = "展示用户信息的相关接口", description = "展示用户的信息")
public class ShowUserController {


    @Autowired
    private ShowUserServiceInterface showUser;

    @GetMapping("showUser")
    @ApiOperation("根据登录的管理员的workerNum展示用户的信息")
    public Result showUser(HttpSession session, @RequestParam(defaultValue ="0") int meterId,@RequestParam(defaultValue = "") String type,@RequestParam(defaultValue = "1") int currentPage){

      String workerNum = (String) session.getAttribute("workerNum");
//        String workerNum ="01";
        log.info("当前showUserController层，参数为："+workerNum+","+meterId+","+type+","+currentPage);

        AllInfo allInfo = showUser.showUser(workerNum, meterId, type, currentPage);

        return Result.success(allInfo);

    }


}